package com.ssuu.ssuusnow.project.manage.log.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ssuu.ssuusnow.model.result.ResultVo;
import com.ssuu.ssuusnow.project.manage.log.entity.Log;
import com.ssuu.ssuusnow.project.manage.log.service.impl.LogServiceImpl;
import com.ssuu.ssuusnow.project.manage.menu.entity.Menu;
import com.ssuu.ssuusnow.project.manage.menu.service.impl.MenuServiceImpl;
import com.ssuu.ssuusnow.utils.log.LogPrint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sun
 * @since 2023-06-14
 */
@CrossOrigin
@RestController
@RequestMapping("/log")
@Api(value = "日志",tags = "日志")
@ApiSupport(author = "孙")
public class LogController {

    @Resource
    LogServiceImpl service;
    @PostMapping("/add")
    @LogPrint("新增日志")
    @ApiOperation(value = "新增日志",notes = "新增日志")
    @ApiOperationSupport(ignoreParameters = {"id","createTime","updateTime","userid","isdel"})
    public ResultVo add(@RequestBody Log u) {
        return new ResultVo(service.AddTo(u));
    }
    @PutMapping("/update")
    @LogPrint("修改日志")
    @ApiOperation(value = "修改日志",notes = "修改日志")
    @ApiOperationSupport(ignoreParameters = {"createTime","updateTime","userid","isdel"})
    public ResultVo update(@RequestBody Log u) {
        return new ResultVo(service.UpdateTo(u));
    }
    @DeleteMapping("/del/{id}")
    @LogPrint("删除日志")
    @ApiOperation(value = "删除日志",notes = "删除日志")
    public ResultVo del(@PathVariable(value="id") Long id) {
        return new ResultVo(service.DelTo(id));
    }
    @GetMapping("/getlist")
    @LogPrint("查询日志")
    @ApiOperationSupport(ignoreParameters = {"id","createTime","updateTime","userid","isdel"})
    @ApiOperation(value = "查询日志",notes = "查询日志")
    public ResultVo get(Log u) {
        return new ResultVo(service.listTo(u));
    }
}
